//
//  UserViewController.m
//  豆瓣电影app
//
//  Created by 洛洛大人 on 16/6/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "UserViewController.h"
#import "userModel.h"
#import "LoginViewController.h"

@interface UserViewController ()<UITableViewDataSource, UITableViewDelegate>
@property(nonatomic, retain)NSArray *modelArray;

@end

@implementation UserViewController
-(void)dealloc{
    [_modelArray release];
    [super dealloc];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self config];

    [self creatTableView];
 
}

-(void)viewWillAppear:(BOOL)animated{
    
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.41 green:0.61 blue:0.68 alpha:1];
}

-(void)config {
    self.modelArray  = [NSArray arrayWithObjects: @"我的活动", @"我的电影", @"清除缓存", nil];
    self.navigationItem.title = @"用户";
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"注销" style:UIBarButtonItemStylePlain target:self action:@selector(rightAction:)];
    
}

-(void)rightAction:(UIBarButtonItem *)item{
    LoginViewController *loginVC = [[LoginViewController alloc]init];
    
    [self.navigationController pushViewController:loginVC animated:YES];
     
     [loginVC release];
    
    
}


-(void)creatTableView {
    
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    [self.view addSubview:tableView];
    tableView.rowHeight = 80;
    
    tableView.delegate = self;
    tableView.dataSource = self;
    
    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
}



-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    NSString *str = [self.modelArray objectAtIndex:indexPath.row];
    
    cell.textLabel.text = str;
    return cell;
    
    
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.modelArray.count;
}














@end
